<!-- start: Container -->
<?php
$gel = '';
if (isset($data['gel'])) {
    $gel = $data['gel'];
}
if (!isset($mess)) {
    $mess = '';
}
?>
<div class="container">
    <!-- start: Page Title Icon-->
    <div id="page-title-icon"></div>
    <div id="page-title-icon-inner">
        <i class="ico-google-maps ico-white"></i>
    </div>
    <!-- end: Page Title Icon-->
    <!-- start: Page Title -->
    <section id="page-title">
        <h2>Đăng Tin - Bước 2</span></h2>
    </section>
</div>
<div id="wrapper" class="white-wrapper">
    <!-- end: Container  -->
    <!-- start: Container -->
    <div class="container">

        <!-- start: Contact Form -->
        <div class="sixteen columns">

            <div class="form-spacer"></div>

            <!-- Success Message -->
            <div class="success-message">
                <div class="notification success closeable">
                    <p><span>Success!</span> Your message has been sent.</p>
                </div>
            </div>
            <?php
            if ($mess != '') {

                ?>
                <div class="error">
                    <div class="notification error closeable">
                        <p>
                            <?php echo $mess; ?>
                        </p>
                    </div>
                </div>
            <?php
            }
            ?>


            <div>


            </div>
            <!-- start: Contact Form -->
            <div id="contact-form">
                <form method="post" name="registerForm" class="require-validate"
                      action="<?php echo $this->url("register", array('controller' => 'register', 'action' => 'addtopic2')) ?>"
                      enctype="multipart/form-data">
                    <div id="reg" style="<?php
                    if (isset($hide) && $hide == 1) {
                        echo 'display:block';
                    } else {
                        echo 'display: none';
                    }
                    ?>">
                        <h3>Đăng ký</h3>
                        <small style="margin-top: 20px"> Đã có Tài khoản <a id="log-btn">Đăng nhập</a></small>
                        <div class="field" id="notice_noauth">
                            <label>Không muốn làm thành viên <a style="cursor: pointer" id="no_auth">click
                                    here</a></label>
                        </div>
                        <div class="field" id="notice_auth" style="display: none">
                            <label>Muốn đăng ký thành viên <a style="cursor: pointer" id="auth">click
                                    here</a></label>
                        </div>
                        <div class="field">
                            <label>Họ: <span>*</span></label>
                            <input type="text" name="f_name" class="text"/>
                        </div>

                        <div class="field">
                            <label>Tên: <span>*</span></label>
                            <input type="text" name="l_name" class="text"/>
                        </div>

                        <div class="field">
                            <label>Email: <span>*</span></label>
                            <input type="text" name="email" class="text"/>
                        </div>
                        <div class="field">
                            <label>Địa chỉ:</label>
                            <input type="text" name="address" class="text"/>
                        </div>
                        <div class="field" id="field_phone">
                            <label>Số điện thoại: </label>
                            <input type="text" name="phone" class="text"/>
                        </div>
                        <div id="user">
                        <div class="field" id="field_pass">
                            <label>Mật khẩu: <span>*</span></label>
                            <input type="password" name="password" class="text"/>
                        </div>

                        <div class="field" id="field_rpass">
                            <label>Nhập lại mật khẩu: <span>*</span></label>
                            <input type="password" name="r_password" class="text"/>
                        </div>
                        </div>
                        <div class="clearfix"></div>
                        <div class="field">
                            <?php
                            if (is_array($gel)) {

                                unset($data['gel']);
                                $i = 0;
                                foreach ($gel as $k => $v) {
                                    $i++; ?>
                                    <input type="hidden" name="gel<?php echo $k ?>" value="<?php echo $v ?>">
                                <?php } ?>
                                <input type="hidden" name="geltotal" value="<?php echo $i; ?>">
                            <?php
                            }
                            foreach ($data as $key => $val) {
                                ?>
                                <input type="hidden" name="<?php echo $key ?>" value="<?php echo $val ?>">
                            <?php
                            }
                            ?>
                            <input type="submit" name="submit" id="send" value="Register"/>

                            <div class="loading"></div>
                        </div>
                    </div>
                </form>

                <!-- div login -->
                <form class="require-validate"
                      action="<?php echo $this->url("register", array('controller' => 'register', 'action' => 'addtopic2')) ?>"
                      method="post">
                    <div id="log" style="<?php
                    if (isset($hide) && $hide == 1) {
                        echo 'display:none';
                    } else {
                        echo 'display: block';
                    }
                    ?>">
                        <h3>Đăng nhập</h3>

                        <div class="field">
                            <label>Email: <span>*</span></label>
                            <input type="text" name="username_log" class="text"/>
                        </div>
                        <div class="field">
                            <label>Mật khẩu: <span>*</span></label>
                            <input type="password" name="password_log" class="text"/>
                        </div>
                        <div class="field">
                            <?php

                            if (is_array($gel)) {
                                $i = 0;
                                foreach ($gel as $k => $v) {
                                    $i++; ?>
                                    <input type="hidden" name="gel<?php echo $k ?>" value="<?php echo $v ?>">
                                <?php } ?>
                                <input type="hidden" name="geltotal" value="<?php echo $i; ?>">
                            <?php
                            }
                            foreach ($data as $key => $val) {
                                ?>
                                <input type="hidden" name="<?php echo $key ?>" value="<?php echo $val ?>">
                            <?php
                            }
                            ?>
                            <input type="submit" name="submit" id="send" value="Login"/>

                            <div class="loading"></div>
                        </div>
                        <br/>
                        <small>Chưa có tài khoản</small>
                        <a id="reg-btn" style="cursor: pointer">Đăng ký</a> ngay!
                </form>
            </div>
        </div>
        <!-- end: Contact Form -->

    </div>
    <!-- end: Contact Form -->

</div>
<!-- end: Container -->
</div>
<script>
    $(document).ready(function () {
        $('#no_auth').click(function () {
            $("h3").text("Khách vãng lai");
            $("#notice_noauth").fadeOut();
            $("#notice_auth").fadeIn();
            $("#field_rpass").remove();
            $("#field_pass").remove();
        });
        $('#auth').click(function () {
            $("h3").text("Đăng ký là thành viên");
            $("#notice_noauth").fadeIn();
            $("#notice_auth").fadeOut();
            var content = ' <div class="field" id="field_pass">'+
                '<label>Mật khẩu: <span>*</span></label>'+
            '<input type="password" name="password" class="text"/>'+
                '</div> '+
            '<div class="field" id="field_rpass">' +
               '<label>Nhập lại mật khẩu: <span>*</span></label>'+
            '<input type="password" name="r_password" class="text"/> '+
               ' </div>';
            $("#user").append(content);

        });
        $("#reg-btn").click(function () {
            $("#log").fadeOut(500);
            $("#reg").fadeIn(500);
        });
        $("#log-btn").click(function () {
            $("#reg").fadeOut(500);
            $("#log").fadeIn(500);
        });
    });
</script>